package com.aso114.project.util;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

/**
 * username:Created by hsj on 2016/10/30 0030.
 * class：
 * 类描述：活动管理器
 */

public class ActivityCollector {
    public static List<Activity> activities = new ArrayList<Activity>();
    //当前显示的activity
    private static Activity currentActivity;

    public static Activity getCurrentActivity() {
        return currentActivity;
    }

    public static void setCurrentActivity(Activity currentActivity) {
        ActivityCollector.currentActivity = currentActivity;
    }

    /**
     * 添加活动
     *
     * @param activity
     */
    public static void addActivity(Activity activity) {
        activities.add(activity);
    }

    /**
     * 删除活动
     *
     * @param activity
     */
    public static void reomveActivity(Activity activity) {
        activities.remove(activity);
    }

    /**
     * 删除所有活动
     */
    public static void removeAllActivity() {
        for (Activity activity : activities) {
            if (!activity.isFinishing()) {
                activity.finish();
            }
        }
    }

}
